import java.util.Scanner;

public class 蓝桥杯斐波那契数组 {
    /*
    https://www.luogu.com.cn/problem/P8808
    枚举枚举, 我开始枚举的有问题也过了90挺奇怪的, 主要是注意后30个以后, 斐波那契数列增长非常快
    导致30以后不需要进行枚举, 一定是需要修改的, 减少枚举次数
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        //这种节省空间
        int a = arr[0];
        int b = arr[1];
        int c = 0;
        int count = 0;
        int minCount = Integer.MAX_VALUE;
        for (int i = 1; i < 1000000; i++) {
            a = i;
            b = i;
            count = 0;
            if (arr[0] != a){
                count++;
            }
            if (arr[1] != b){
                count++;
            }
            for (int j = 2; j < Math.min(30,n); j++) {
                c = a + b;
                if(c != arr[j]){
                    count++;
                }
                a = b;
                b = c;
            }
            minCount = Math.min(minCount,count);
        }
        if(n > 30){
            minCount += n - 30;
        }
        System.out.println(minCount);
    }
}
